<?php

namespace App\Http\Queries;

use App\Models\Referee;
use Spatie\QueryBuilder\QueryBuilder;
use Spatie\QueryBuilder\AllowedFilter;

class RefereeQuery extends QueryBuilder
{
    public function __construct()
    {
        parent::__construct(Referee::query());
        $this->allowedIncludes('user');
        $this->allowedFilters([
            'name',
            'province',
            'city',
            AllowedFilter::exact('phone'),
            AllowedFilter::exact('user_id'),
            AllowedFilter::scope('dealer_code')
        ]);
        $this->defaultSort('-id');
    }
}
